import socket,random

server=socket.socket()
ip_port=('127.0.0.1',8888)
server.bind(ip_port)
server.listen(5)
while True:
    print('Waiting for accepting data...')
    connection,address=server.accept()
    start='Connection build...'
    connection.send(start.encode(encoding='utf-8'))
    while True:
        data=connection.recv(1024)
        print(data.decode(encoding='utf-8'))
        if data == b'exit':
            break
        connection.send(data)
        connection.send(str(random.randint(1,1000)).encode(encoding='utf-8'))
    end='Connection closed...'
    connection.send(end.encode(encoding='utf-8'))
    connection.close()
